﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Reconciliation.Services;
using System.Text;
using System.Collections.Generic;

namespace Reconciliation.Web.Users_Control
{
    public partial class StatusComments : System.Web.UI.UserControl
    {
        private int CaseId;
        public int CaseID
        {
            get
            {
                return CaseId;
            }
            set { CaseId = value; }

        }

        private string commentType;
        public string CommentType
        {
            get
            {
                return commentType;
            }
            set { commentType = value; }

        }

        protected void Page_Load(object sender, EventArgs e)
        {
            lblComment.Text = "Comment: " + GetClientComment(CaseID);
        }

        private string GetClientComment(int CaseId)
        {
            StringBuilder strComment = new StringBuilder();
            
            List<CaseComment> CommentList = new List<CaseComment>();

            if (CommentType == "Client")
            {
                CommentList = Reconciliation.Services.Services.GetCaseClientComment(CaseId).ToList<Reconciliation.Services.CaseComment>();
            }
            else
            {
                CommentList = Reconciliation.Services.Services.GetCaseAuditorComment(CaseId).ToList<Reconciliation.Services.CaseComment>();
            }

            foreach (CaseComment cm in CommentList)
            {
                strComment.Append(cm.Comment);
            }
            
            return strComment.ToString();

        }
    }
}